package com.htsk.city.services.wechat.config;

import cn.dev33.satoken.interceptor.SaInterceptor;
import cn.dev33.satoken.router.SaRouter;
import cn.dev33.satoken.stp.StpUtil;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * @Author：mjiaxing
 * @CreateTime：2023-03-28
 * @Description：Sa-Token 路由拦截鉴权
 * @Version：1.0.0
 */
@Configuration
public class SaTokenConfigure implements WebMvcConfigurer {


    // 注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册 Sa-Token 拦截器，定义详细认证规则
//        registry.addInterceptor(new SaInterceptor(handler -> {
//            // 登录验证
//            SaRouter.match("/**").notMatch(
//                    "/login",
//                    "/logout",
//                    "/statics/**",
//                    "/job/query",
//                    "/job/queryJobFair",
//                    "/job/queryJobBoard",
//                    "/portal/*",
//                    "/company/query").check(r -> StpUtil.checkLogin());
//        })).addPathPatterns("/**");
    }

}
